<!DOCTYPE html>
<html lang="zh">
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/header :: header(~{::title},~{::link},~{})">

    <title>日报列表</title>
    <link rel="icon" th:href="@{/assets/img/lcxm.ico}" type="image/ico">
    <link rel="stylesheet" th:href="@{/assets/css/common.css}">
</head>
<body class="body">
<!--导航-->
<div th:replace="common/nav :: nav(true)"></div>
<div class="container-fluid">
    <!--<div class="page-header" style="margin-top: 20px;top:50%;">
        <h1 class="text-primary">凯捷科技 <small>简易点餐</small></h1>
    </div>-->
    <div class="row row-nocol">

        <form class="form-inline lookup" role="form" method="post">

            <div class="form-group" style="margin-left: 5px">
                <label class="control-label sr-only" for="lookup-code">jira号</label>
                <div class="input-group">
                    <input class="form-control input-sm" id="lookup-code" name="code" type="text"
                           th:value="${ pager?.lookup?.code}" placeholder="jira号">
                </div>
            </div>

            <div class="form-group" style="margin-left: 5px">
                <label class="control-label sr-only" for="lookup-pcode">父jira号</label>
                <div class="input-group">
                    <input class="form-control input-sm" id="lookup-pcode" name="pcode" type="text"
                           th:value="${ pager?.lookup?.pcode}" placeholder="父jira号">
                </div>
            </div>
            <div class="form-group " style="margin-left: 5px">
                <label class="control-label sr-only" for="lookup-company-id">所属项目</label>
                <div class="input-group">
                    <select class="form-control input-sm select2" id="lookup-company-id" name="projectId"
                            style="max-width: 20em;"
                            data-placeholder="选择所属项目"
                            data-allow-clear="true"
                            th:attr="data-value=${ pager?.lookup?.projectId}" data-url="project/all">
                        <option value="">选择所属项目</option>
                    </select>
                </div>
            </div>

            <div class="form-group" style="margin-left: 5px">
                <label class="control-label sr-only" for="lookup-status">状态</label>
                <div class="input-group">
                    <input class="form-control input-sm" id="lookup-status" name="status" type="text"
                           th:value="${ pager?.lookup?.status}" placeholder="状态">
                </div>
            </div>
            <div class="form-group" style="margin-left: 5px">
                <label class="control-label sr-only" for="lookup-type">类型</label>
                <div class="input-group">
                    <input class="form-control input-sm" id="lookup-type" name="type" type="text"
                           th:value="${ pager?.lookup?.type}" placeholder="类型">
                    </select>
                </div>
            </div>
            <div class="form-group" style="margin-left: 5px">
                <label class="control-label sr-only" for="lookup-checkResult">检测结果</label>
                <div class="input-group">
                    <select style="width: 100%" class="form-control input-sm" id="lookup-checkResult" name="checkResult"
                            th:attr="data-value=${ pager?.lookup?.checkResult}">
                        <option value="">--jira号检测结果--</option>
                        <option th:each="item:${checkResults}" th:value="${item.name()}"
                                th:text="${item.getText()}"></option>
                    </select>
                </div>
            </div>


            <div class="form-group" style="margin-left: 5px">
                <label class="control-label sr-only" for="lookup-assignee">经办人</label>
                <div class="input-group">
                    <input class="form-control input-sm" id="lookup-assignee" name="assignee" type="text"
                           th:value="${ pager?.lookup?.assignee}" placeholder="经办人"/>
                </div>
            </div>
            <div class="form-group pull-right">
                <button type="submit" class="btn btn-primary btn-sm">
                    <i class="glyphicon glyphicon-search"></i> 查询
                </button>
                <button type="button" class="btn btn-info btn-sm reset">
                    <i class="glyphicon glyphicon-refresh"></i> 重置
                </button>
            </div>

        </form>
        <hr/>
        <!-- 操作信息提示的地方 -->
        <div th:if="${remind}" class="alert alert-${ remind.level  }"
             th:classappend="'alert-' + ${remind.level}">
            <button data-dismiss="alert" class="close" type="button">
                <i class="glyphicon glyphicon-remove"></i>
            </button>
            <span th:remove="tag" th:utext="${ remind.message }"></span>
        </div>
        <!--列表栏-->
        <form class="nocol">

            <div class="action-bar">
                <!-- <a class="btn btn-sm btn-success" th:href="@{/jira/form}" title="新增jira">
                     <i class="glyphicon glyphicon-plus"></i> 新增jira
                 </a>-->
                <a class="btn btn-sm btn-primary" data-toggle="tooltip" title="根据jira号从jira系统拉取jira信息" onclick="importJira();">
                    <i class="glyphicon glyphicon-import"></i> 根据jira号导入
                </a>
            </div>

            <table class="table table-striped  table-hover table-bordered stable">
                <thead>
                <tr class="text-center">
                    <th>Jira号</th>
                    <th>父Jira号</th>
                    <th>所属项目</th>
                    <th class="small">结算年度</th>
                    <th class="small">预计工时</th>
                    <th>状态</th>
                    <th>类型</th>
                    <th class="small" data-toggle="tooltip" title="从jira系统查询的结果">检测结果</th>
                    <th class="small">报告人</th>
                    <th>经办人</th>
                    <th>修复版本</th>
                    <th>修复日期</th>
                    <th>内容</th>
                    <th class="text-info">操作</th>
                </tr>
                </thead>
                <tbody align="center">
                <tr th:each="cur:${pager?.datas}" class="small">
                    <td  class="text-info">
                        <a class="text-info action-get"
                                th:text="${cur.code}"
                                th:attr="data-url='/jira/reportDetail/'+${cur.code}"
                                data-toggle="tooltip"
                                title="查看工时详情" data-confirm="进入工时详情页面会进行一次工时统计,确定查看工时详情吗?">
                        </a>
                    </td>
                    <td>
                        <a class="text-info action-get" type="button"
                                th:text="${cur.pcode}"
                                th:attr="data-url='/jira/reportDetail/'+${cur.pcode}"
                                data-toggle="tooltip"
                                title="查看工时详情" data-confirm="进入工时详情页面会进行一次工时统计,确定查看工时详情吗?">
                        </a>
                    </td>
                    <td th:text="${#strings.abbreviate(cur.projectName,15)}" data-toggle="tooltip" th:title="${cur.projectName}">projectName
                    </td>
                    <td th:text="${cur.settleYear}">companyName</td>
                    <td>
                        <span th:text="${cur.duration}" class="label label-default" data-toggle="tooltip" th:title="'已用:'+${cur.getTotalUsedPersonDays()}"></span>

                    </td>
                    <td th:text="${cur.status}">status</td>
                    <td th:text="${cur.type}">type</td>
                    <td th:text="${cur.checkResult?.getText()}">checkResult</td>
                    <td th:text="${cur.reporter}">reporter</td>
                    <td th:text="${cur.assignee}">assignee</td>
                    <td th:text="${#strings.abbreviate(cur.versionName,10)}" th:title="${cur.versionName}">versionName
                    </td>
                    <td th:text="${#dates.format(cur.releaseDate, 'yyyy-MM-dd')}"></td>
                    <td th:text="${#strings.abbreviate(cur.content,20)}" data-toggle="tooltip" th:title="${cur.content}">content</td>
                    <td>
                        <div class="btn-group-dis">
                            <button th:if="${cur.couldEdit}" class="btn btn-xs btn-info action-get" type="button"
                                    th:attr="data-url='/jira/edit/'+${cur.id}"
                                    data-toggle="tooltip"
                                    title="编辑" data-confirm="确定需要编辑当前jira吗?">
                                <i class="glyphicon glyphicon-edit"></i>
                            </button>

                            <!--<button th:if="${cur.couldEdit}" class="btn btn-xs btn-warning action-get" type="button"
                                    th:attr="data-url='/jira/summary/'+${cur.code}"
                                    data-toggle="tooltip"
                                    title="工时统计" data-confirm="定时器和相关操作时已做统计，此按钮为实时统计jira相关的工时。<p style='color:red;'>确定统计当前jira的工时吗?</p>">
                                <i class="glyphicon glyphicon-stats"></i>
                            </button>-->
                            <button th:if="${cur.checkResult.name() == 'notExist'}"
                                    class="btn btn-xs btn-danger action-post"
                                    type="button"
                                    th:attr="data-url='/jira/delete/'+${cur.id}"
                                    data-toggle="tooltip"
                                    title="删除" data-confirm="确定删除吗?">
                                <i class="glyphicon glyphicon-trash"></i>
                                <!-- <i class="action-param" data-key="date" th:attr="data-value=${day.day}"></i>-->
                            </button>
                        </div>
                    </td>
                </tr>
                <!-- </c:forEach> -->
                </tbody>
            </table>

        </form>
        <!--页码相关-->
        <div th:replace="common/pager :: pager"></div>
    </div>


</div>

<!-- 引入通用js-->
<div th:replace="common/footer :: footer"></div>
<script>

    function importJira() {
        $.confirm({
            title: '根据jira号导入jira系统的jira信息!',
            content: 'url:' + ctx + "jira/import/",
            columnClass: 'col-md-8 col-md-offset-2 ',
            buttons: {
                取消: function () {
                },
                somethingElse: {
                    text: '确定',
                    btnClass: 'btn-blue',
                    action: function () {
                        let projectId = this.$content.find('#projectId').val();
                        let code = this.$content.find('#code').val();
                        if (!projectId || !code) {
                            $.alert("请完整输入jira号和所属项目!");
                            return false;
                        }
                        let result = common.checkJiraCode(code);
                        if (!result) {
                            return false;
                        }
                        return importJiraByCode({code: code, projectId: projectId});
                    }
                }
            }
        });

    }

    function importJiraByCode(data) {
        let result = true;
        $.ajax({
            async: false,
            url: ctx + 'jira/import',
            type: 'post',
            data: data,
            success: function (res) {
                if (res.success) {
                    $.alert({
                        title: '操作成功',
                        content: '',
                        onClose: function () {
                            window.location.reload();
                        }
                    });
                } else {
                    $.alert(res.msg);
                    result = false;
                }
            }
        });
        debugger

        return result;


    }


    function clickDate(id) {
        $.alert({
            theme: 'bootstrap',
            title: '当日工作详情',
            columnClass: 'col-md-10 col-md-offset-1',
            content: "url:" + (ctx + "report/day/" + id)
        });
    }

</script>
</body>
</html>